<template>
    <el-form ref="articleForm" @submit.native.prevent="saveArticle" :model="article" label-width="80px">
        <el-form-item label="文章标题" prop="title">
            <el-input v-model="article.title"></el-input>
        </el-form-item>

        <el-form-item label="文章内容" prop="content">
            <el-input type="textarea" v-model="article.content"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" native-type="submit">立即创建</el-button>
            <el-button>取消</el-button>
        </el-form-item>
    </el-form>
</template>


<script>
export default {
    data() {
        return {
            article: {
                title: "",
                content: "",   
            }
        }
    },
    methods: {
        saveArticle() {
            console.log(this.article);
            this.$http.post('/articles/create', this.article)
            .then((res) => {
                this.$message('操作成功')
            })
            this.$router.push('/articles/index')
            
        }
    }
}
</script>